//
//  AESubmitOrderBottomView.m
//  AESOLAR_IOS
//
//  Created by Bin Tang on 2024/10/15.
//  Copyright © 2024 Mr.Wang. All rights reserved.
//

#import "AESubmitOrderBottomView.h"
#import "AE_Solar-Swift.h"

@interface AESubmitOrderBottomView ()

/// 提交订单
@property (nonatomic, strong) UIButton *btnSubmitOrder;

/// 合计
@property (nonatomic, strong) UILabel *titleLabel;

/// 积分
@property (nonatomic, strong) UILabel *cntLabel;

@end

@implementation AESubmitOrderBottomView

- (void)initWithSubView {
    [super initWithSubView];
    
    self.backgroundColor = kWhiteColor;
    
    [self initWithBtnSubmitOrder];
    
    [self initWithTitleLabel];
}


/// 提交订单
- (void)initWithBtnSubmitOrder {
    if (!_btnSubmitOrder) {
        NSString *title = [AEStringExten localizedValueWithKey:@"提交订单"];
        UIFont *font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
        float width = [title widthForFont:font] + 2 + 28 * 2;
        CGRect frame = CGRectMake(self.width - width - 10, (49 - 40) * 0.5, width, 40);
        _btnSubmitOrder = [UIButton createWithButton:self frame:frame font:font target:self action:@selector(actionWithSubmitOrder:) propertiesBlock:^(UIButton * _Nonnull button) {
            [button setTitle:title forState:UIControlStateNormal];
            [button setTitleColor:kWhiteColor forState:UIControlStateNormal];
            button.backgroundColor = [UIColor colorWithHexString:@"#F6020A"];
            button.layer.cornerRadius = frame.size.height * 0.5;
        }];
    }
}

- (void)initWithTitleLabel {
    if (!_titleLabel) {
        NSString *title = [AEStringExten localizedValueWithKey:@"合计"];
        UIFont *font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
        float width = [title widthForFont:font] + 2;
        CGRect frame = CGRectMake(15, (49 - 30) * 0.5, width, 30);
        _titleLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#333333"];
            label.text = title;
        }];
    }
}

/// 积分
- (void)initWithCntLabel {
    if (!_cntLabel) {
        CGRect frame = CGRectMake(self.titleLabel.right + 8, (49 - 30) * 0.5, self.btnSubmitOrder.left - self.titleLabel.right - 8 - 10, 30);
        _cntLabel = [UILabel createWithLabel:self frame:frame font:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium] propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#F6020A"];
        }];
    }
    NSString *cnt = [AEStringExten localizedValueWithKey:@"积分"];
    NSString *title = [NSString stringWithFormat:@"%@%@", @"889", cnt];
    self.cntLabel.text = title;
}

/// 提交订单
/// - Parameter sender: sender description
- (void)actionWithSubmitOrder:(id)sender {
    if (self.touchSubmitOrderBlock) {
        self.touchSubmitOrderBlock();
    }
}

- (void)updateWithViewData:(id)data {
    
    
    [self initWithCntLabel];
}

@end
